home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
2.3
/
Actalk=2.3.st
next >
Wrap
Text File
|
1993-07-24
|
5KB
|
225 lines
" NAME Actalk
AUTHOR IWW@cs.man.ac.uk
FUNCTION quick hack to play with actor-like things - see Briot ECOOP89
ST-VERSIONS 2.4
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION 1.1
DATE 25 Jan 1989
SUMMARY Actalk
A quick, simple hack for playing around with actor like
things in st80. See ""Actalk: a Testbed for Classifying and
Designing Actor Languages in the Smalltalk-80 Environment"",
Jean-Pierre Briot, ECOOP 89. (2.3,2.4). IWW.
"!
Object subclass: #MinimalObject
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Kernel'!
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
MinimalObject class
instanceVariableNames: ''!
!MinimalObject class methodsFor: 'initialisation'!
initialise
superclass _ nil.
#(#doesNotUnderstand: #error: #~~ #isNil #= #== #printString #printOn: #class #inspect #basicInspect #basicAt: #basicSize #instVarAt:put: ) do: [:selector | self recompile: selector from: Object]! !
MinimalObject subclass: #Actor
instanceVariableNames: 'mailBox behaviour '
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Kernel'!
MinimalObject initialise!
!Actor methodsFor: 'message passing'!
asynchronousSend: aMessage
mailBox nextPut: aMessage!
doesNotUnderstand: aMessage
self asynchronousSend: aMessage! !
!Actor methodsFor: 'access'!
mailBox
^mailBox! !
!Actor methodsFor: 'initialisation'!
initialise
mailBox _ SharedQueue new!
initialiseBehaviour: aBehaviour
behaviour _ aBehaviour.
behaviour initialiseAself: self.! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
Actor class
instanceVariableNames: ''!
!Actor class methodsFor: 'initialisation'!
behaviour: aBehaviour
^self new initialiseBehaviour: aBehaviour! !
!Actor class methodsFor: 'instance creation'!
new
^super new initialise! !
Object subclass: #ActorBehaviour
instanceVariableNames: 'aself '
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Kernel'!
!ActorBehaviour methodsFor: 'actor creation'!
actor
^Actor behaviour: self! !
!ActorBehaviour methodsFor: 'message acceptance'!
acceptMessage: aMessage
self performMessage: aMessage.!
acceptNextMessage
self acceptMessage: aself mailBox next! !
!ActorBehaviour methodsFor: 'initialisation'!
initialiseAself: anActor
aself _ anActor.
self setProcess!
setProcess
[[true]
whileTrue: [self acceptNextMessage]] fork! !'From Smalltalk-80, Version 2.4 of 28 January 1989 on 17 July 1989 at 4:27:09 pm'!
!Object methodsFor: 'message handling'!
performMessage: aMessage
^self perform: aMessage selector withArguments: aMessage arguments! !ActorBehaviour subclass: #AghaActorBehaviour
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Extensions-Agha'!
!AghaActorBehaviour methodsFor: 'behaviour replacement'!
replace: replacementBehaviour
aself initialiseBehaviour: replacementBehaviour! !
!AghaActorBehaviour methodsFor: 'initialisation'!
setProcess
[self acceptNextMessage] fork! !AghaActorBehaviour subclass: #AghaCounter
instanceVariableNames: 'contents '
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Examples'!
!AghaCounter methodsFor: 'script'!
consultAndReplyTo: replyDestination
self replace: self.
replyDestination reply: contents!
incr
self replace: (AghaCounter contents: contents + 1)!
reset
self replace: (AghaCounter contents: 0)! !
!AghaCounter methodsFor: 'initialisation'!
initialiseWithContents: aValue
contents _ aValue! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
AghaCounter class
instanceVariableNames: ''!
!AghaCounter class methodsFor: 'examples'!
example1
"Make print a global print actor that will print the result"
"Print _ Printer new actor.
AghaCounter example1"
| aCounter |
aCounter _ AghaCounter new actor.
aCounter reset; incr; incr; consultAndReplyTo: Print! !
!AghaCounter class methodsFor: 'instance creation'!
contents: aValue
^super new initialiseWithContents: aValue! !
ActorBehaviour subclass: #Counter
instanceVariableNames: 'contents '
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Examples'!
!Counter methodsFor: 'script'!
consultAndReplyTo: replyDestination
replyDestination reply: contents!
consultAnReplyTo: replyDestination
replyDestination reply: contents!
incr
contents _ contents + 1!
reset
contents _ 0! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
Counter class
instanceVariableNames: ''!
!Counter class methodsFor: 'examples'!
example1
"Make print a global print actor that will print the result"
"Print _ Printer new actor.
Counter example1"
| aCounter |
aCounter _ Counter new actor.
aCounter reset; incr; incr; consultAndReplyTo: Print! !
ActorBehaviour subclass: #Printer
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Actalk-Examples'!
!Printer methodsFor: 'script'!
reply: value
Transcript show: '>' , value printString; cr! !